package com.zzx.threekingdom.card;

import com.zzx.threekingdom.card.BaseCard.BaseCardType;
import com.zzx.threekingdom.card.EquipmentCard.EquipmentCardType;
import com.zzx.threekingdom.card.KnowhowCard.KnowhowCardType;
import com.zzx.threekingdom.card.Pattern.Color;
import com.zzx.threekingdom.card.Pattern.Points;
import com.zzx.threekingdom.judge.Judge;


public class CardHeap
{
    public CardList playCards = new CardList();
    public CardList characterCards  = new CardList();
    public CardList identityCards = new CardList();
    public CardList trashPlayCards = new CardList();
    
    public static CardHeap cardHeap;
    
    private CardHeap()
    {
        playCards.clear();
        //addBaseCardList(playCards);
        //addEquipmentCardList(playCards);
        addKnowhowCardList(playCards);
        characterCards.clear();
        addCharactereCardList(characterCards);
        identityCards.clear();
        addidentityCardList(identityCards);
        trashPlayCards.clear();
    }
    
    public static void reload()
    {
        cardHeap = null;
        cardHeap = new CardHeap();
    }
    
    public void addTrashCards(CardList cards) { trashPlayCards.addCards(cards); }
    public void addTrashCard(Card card) { if(card!=null) trashPlayCards.addCard(card); }
    
    public CardList drawPlayCards(int num)
    {
        if(num < playCards.size())
            return playCards.drawCards(num);
        
        CardList retCards = playCards.drawCards(num);
        
        if(playCards.size()<=0&&trashPlayCards.size()>0)
        {
            Judge.judge.addLog("从废牌堆中取牌");
            playCards.addCards(trashPlayCards);
            trashPlayCards.clear();
            if(playCards.size()==0)
            {
                Judge.judge.isGameEnd();
                return retCards;
            }
            
            Judge.judge.addLog("开始洗牌");
            playCards.shuffle();
        }
        
        
        
        int lackNum = num - retCards.size();
        if(lackNum > 0)
        {
            retCards.addCards(playCards.drawCards(lackNum));
        }
        
        
        
        
        return retCards;
    }
    
    public Card getOneJudgeCard()
    {
        CardList cards = drawPlayCards(1);
        return cards.size()!=0?cards.get(0):null;
    }
    
    
    
    
    
    
    
    
    public void addBaseCardList(CardList baseCardList)
    {
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.six));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.seven));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.diamond, Points.king));
        
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.seven));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.spade, Points.ten));
        
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.heart, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.heart, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.heart, Points.jack));
        
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.three));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.four));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.five));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.six));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.seven));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.jack));
        baseCardList.add(new BaseCard(BaseCardType.kill, Color.club, Points.jack));
        
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.three));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.four));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.five));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.six));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.seven));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.ten));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.jack));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.diamond, Points.jack));
        
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.heart, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.heart, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.evade, Color.heart, Points.king));
        
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.diamond, Points.two));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.diamond, Points.queen));
        
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.three));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.four));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.seven));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.eight));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.nine));
        baseCardList.add(new BaseCard(BaseCardType.peach, Color.heart, Points.queen));
    }
    public void addEquipmentCardList(CardList equipmentCardList)
    {
        
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.addhorse, Color.heart, Points.king, "爪黄飞电"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.addhorse, Color.club, Points.five, "的卢"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.addhorse, Color.spade, Points.five, "绝影"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.reducehorse, Color.heart, Points.five, "赤兔"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.reducehorse, Color.diamond, Points.king, "紫骍"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.reducehorse, Color.spade, Points.king, "大宛"));
        
        
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.diamond, Points.ace, "诸葛连弩", 1));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.club, Points.ace, "诸葛连弩", 1));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.spade, Points.two, "寒冰剑", 2));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.spade, Points.six, "青釭剑", 2));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.spade, Points.two, "雌雄双股剑", 2));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.diamond, Points.five, "贯石斧", 3));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.spade, Points.ace, "青龙偃月刀", 3));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.spade, Points.queen, "丈八蛇矛", 3));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.diamond, Points.queen, "方天画戟", 4));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.weapon, Color.heart, Points.five, "麒麟弓", 5));
        
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.armor, Color.club, Points.two, "八卦阵"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.armor, Color.spade, Points.two, "八卦阵"));
        equipmentCardList.add(new EquipmentCard(EquipmentCardType.armor, Color.club, Points.two, "仁王盾"));
    }
    
    public void addKnowhowCardList(CardList knowhowCardList)
    {
        
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.lightning, Color.spade, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.lightning, Color.heart, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.leaveallbehind, Color.club, Points.six));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.leaveallbehind, Color.heart, Points.six));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.leaveallbehind, Color.spade, Points.six));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.impeccable, Color.diamond, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.impeccable, Color.spade, Points.jack));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.impeccable, Color.club, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.impeccable, Color.club, Points.king));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.getknifetokill, Color.club, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.getknifetokill, Color.club, Points.king));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.harvest, Color.heart, Points.three));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.harvest, Color.heart, Points.four));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.outofnothing, Color.heart, Points.seven));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.outofnothing, Color.heart, Points.eight));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.outofnothing, Color.heart, Points.nine));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.outofnothing, Color.heart, Points.jack));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.duel, Color.diamond, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.duel, Color.spade, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.duel, Color.club, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.allpeach, Color.heart, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.alieninvade, Color.spade, Points.seven));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.alieninvade, Color.spade, Points.king));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.alieninvade, Color.club, Points.seven));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.swarmofarrows, Color.heart, Points.ace));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.steal, Color.diamond, Points.three));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.steal, Color.diamond, Points.four));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.steal, Color.spade, Points.three));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.steal, Color.spade, Points.four));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.steal, Color.spade, Points.jack));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.spade, Points.three));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.spade, Points.four));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.spade, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.heart, Points.queen));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.club, Points.three));
        knowhowCardList.add(new KnowhowCard(KnowhowCardType.remove, Color.club, Points.four));
        
        
    }
    public void addCharactereCardList(CardList characterCardList)
    {
        characterCardList.add(new CharacterCard("刘备", 4));
        characterCardList.add(new CharacterCard("关羽", 4));
        characterCardList.add(new CharacterCard("张飞", 4));
        characterCardList.add(new CharacterCard("诸葛亮", 3));
        characterCardList.add(new CharacterCard("赵云", 4));
        characterCardList.add(new CharacterCard("马超", 4));
        characterCardList.add(new CharacterCard("黄月英", 3));
        
        characterCardList.add(new CharacterCard("孙权", 4));
        characterCardList.add(new CharacterCard("甘宁", 4));
        characterCardList.add(new CharacterCard("吕蒙", 4));
        characterCardList.add(new CharacterCard("黄盖", 4));
        characterCardList.add(new CharacterCard("周瑜", 3));
        characterCardList.add(new CharacterCard("大乔", 3));
        characterCardList.add(new CharacterCard("陆逊", 3));
        characterCardList.add(new CharacterCard("孙尚香", 3));
        
        characterCardList.add(new CharacterCard("曹操", 4));
        characterCardList.add(new CharacterCard("司马懿", 3));
        characterCardList.add(new CharacterCard("夏侯敦", 4));
        characterCardList.add(new CharacterCard("张辽", 4));
        characterCardList.add(new CharacterCard("许褚", 4));
        characterCardList.add(new CharacterCard("郭嘉", 3));
        characterCardList.add(new CharacterCard("甄姬", 3));
        
        characterCardList.add(new CharacterCard("华佗", 3));
        characterCardList.add(new CharacterCard("吕布", 4));
        characterCardList.add(new CharacterCard("貂蝉", 3));
        
    }
    
    public void addidentityCardList(CardList identityCardList)
    {
        
    }

}
